import instance from "@/config/axiosConfig.js";

const menu = {
    permissionsTreeList: () => {
        return instance.get("/sys/menu/getPermissionsTreeList").then(res => {
            return res.data
        });
    },
    queryMenuList: (params) => {
        return instance.get("/sys/menu/getAllMenuList", {params}).then(res => {
            return res.data;
        });
    },
    queryMenuListByRoleId: (params) => {
        return instance.get(`/sys/menu/getMenuListByRoleId/${params.roleId}`, {params}).then(res => {
            return res.data;
        });
    },
    editMenu: (data) => {
        return instance.post("/sys/menu", data).then(res => {
            return res.data;
        });
    },
    updateRoleMenuByRoleId: (roleId, data) => {
        return instance.put(`/sys/menu-role-bind/${roleId}`, data).then(res => {
            return res.data;
        });
    },
    deleteMenu: (id, menuId) => {
        return instance.delete(`/sys/menu/${id}`, {params: {menuId}}).then(res => {
            return res.data;
        });
    }
}

export default menu;
